﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CountDownManager : MonoBehaviour
{
    // Start is called before the first frame update
    private float totalTime = 99;
    void Start()
    {
        StartCoroutine(CountDown());
    }

    private IEnumerator CountDown()
    {
        while (totalTime > 0 )
        {
            yield return new WaitForSeconds(1);
            if (GameManager.Instance.IsGameStarted)
            {
                totalTime--;
                GameObject go = ObjectPool.Instance.GetActivePlatform();
                var platform = go.GetComponent<NormalPlatform>();
                platform.StartRock();
                StartCoroutine(DestroyPlatform(platform));
            }
        }
    }

    IEnumerator DestroyPlatform(NormalPlatform platform)
    {
        yield return new WaitForSeconds(1);
        platform.DestroyPlatform();
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
